package com.lancoo.cvas.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lancoo.cvas.config.MybatisRedisCache;
import com.lancoo.cvas.entity.*;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lancoo.cvas.pojo.dto.*;
import com.lancoo.cvas.pojo.vo.*;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.List;

/**
 * 教学班
 * 
 * @author liufeng
 * @email 1037383243@qq.com
 * @date 2023-12-04 11:54:00
 */
@CacheNamespace(implementation = MybatisRedisCache.class, eviction = MybatisRedisCache.class)
public interface TeachingClassMapper extends BaseMapper<TeachingClass> {

    /**
     * 批量插入教学班
     * @param teachingClasses
     * @return
     */
    Integer saveBatch(List<TeachingClass> teachingClasses);

    List<PlanTeachingClassCourseVo> selectCourseByTaskId(Integer taskId);

    List<PlanTeachingClassSegmentVo> selectSegmentByTaskId(Integer taskId);

    List<TeachingClass> getCourseFix(Integer taskId, Long courseId, List<RuleCourseProhibitMajor> majors);
    List<TeachingClass> getCourseFixBatch(Integer taskId, List<Long> courseIds, List<RuleCourseProhibitMajor> majors);

    IPage<TeachingClassCourseDto> getCourseTeachingClassForArrange(Page<TeachingClassCourseDto> page, Integer taskId, Integer state,String gradeId, String majorId, String keyword);

    /**
     * 获取环节教学班 排课数据
     * @param page
     * @param taskId
     * @return
     */
    IPage<TeachingClassSegmentDto> getSegmentTeachingClassForArrange(@Param("page") IPage page, @Param("taskId") Integer taskId, String gradeId, String majorId,String type, String keyword);


    /**
     * 获取课程教学班 排课数据
     *
     * @param taskId
     * @param campusId
     * @return
     */
    List<ArrangeTeachingClassDto> getCourseArrangeTeachingClassDto(@Param("taskId") Integer taskId, @Param("campusId") String campusId);

    /**
     * 批量插入拆班班级
     * @param subTeachingClassList
     * @return
     */
    Integer saveSubBatch(List<TeachingClass> subTeachingClassList);


    List<ScheduleDto> getSchedule(Integer taskId);

    /**
     * @Description: 固排禁排  不获取拆班的
     * @Author: liufeng
     * @Date: 2024/1/15 13:53
     * @param taskId:
     * @param roomId:
     * @param teacherId:
     * @param classId:
     * @param teachingClassId:
     * @return:
     */
    List<RuleTeachingClassVo> getRuleTeachingClass(Integer taskId,Long roomId, Long teacherId, Long classId, Long teachingClassId);

    /**
     * 获取课程教学班 主要用于课表，关联数据较少提升速度
     *
     * @param page
     * @param taskId
     * @return
     */
    IPage<TeachingClassCourseDto> getTeachingClass(@Param("page") IPage page, @Param("taskId") Integer taskId,  @Param("teachingClassIds") List<Long> teachingClassIds);


    /**
     * @Description: 行政班 教室 教学班课程用
     * @Author: liufeng
     * @Date: 2024/2/22 18:38
     * @param page:
     * @param taskId:
     * @param classIds:
     * @return:
     */
    IPage<TeachingClassWeekScheduleDto> getTeachingClassSchedule(IPage page, Integer taskId, List<Long> classIds);

    //多教师版本

    /**
     * @Description: 多教师  教师课表相关 根据type
     * @Author: liufeng
     * @Date: 2024/2/22 18:37
     * @param page:
     * @param taskId:
     * @param teachingClassTeachers:
     * @return:
     */
    IPage<TeachingClassWeekScheduleDto> getTeachingClassScheduleTeacher(Page<TeachingClassWeekScheduleDto> page, Integer taskId, List<TeachingClassTeacher> teachingClassTeachers);

    /**
     * @Description: 教师关联课表用 没有page
     * @Author: liufeng
     * @Date: 2024/2/22 18:37
     * @param taskId:
     * @param teachingClassTeachers:
     * @return:
     */
    List<TeachingClassWeekScheduleDto> getTeachingClassScheduleTeacher(Integer taskId, List<TeachingClassTeacher> teachingClassTeachers);

    /**
     * @Description: 教师课表相关用  加入type进行筛选
     * @Author: liufeng
     * @Date: 2024/2/22 18:38
     * @param taskIds:
     * @param teacherId:
     * @param deleted:
     * @return:
     */
    List<TeachingClassTeacher> getTeacherTeachingClassByTaskId(List<Integer> taskIds, Long teacherId, int deleted);

    List<GenerateTeachingClassUnitInput> getAllUnArrangeTeachingClass(Integer taskId,Integer state);

    /**
     * 确定选课列表 获取在线选课教学班
     * @param page
     * @param taskId
     * @param handleState
     * @param courseId
     * @param keyWord
     * @param minClassNum
     * @return
     */
    IPage<TeachingClassCourseDto> getSelectionTeachingClass(Page<TeachingClassCourseDto> page, Integer taskId, Integer handleState, Long courseId, String keyWord, Integer minClassNum);

    /**
     *
     *根据教学班类型
     * @param taskId
     * @param teachingClassType
     * @return
     */
    List<TeachingClassCourseDto> getSelectStatistic(Integer taskId, Integer teachingClassType);

    /**
     * 获取选课去重人数
     * @param taskId
     * @param teachingClassType
     * @return
     */
    Integer getSelectStudent(Integer taskId, Integer teachingClassType);

    /**
     *退选统计-在线选课
     * @param taskId
     * @return
     */
    List<TeachingClassCourseDto> getDeselectStatistic(Integer taskId);

    List<SyncTeachingClassDto> syncCourseTeachingClassDto(Integer taskId);

    List<SyncTeachingClassDto> syncSegmentTeachingClassDto(Integer taskId);

    List<TeachingClass> selectListByRoomId(Integer taskId, Long roomId);
    List<TeachingClass> selectListByRoomIdHasWeekNum(Integer taskId, Long roomId);

    IPage<TeachingClassCourseDto> getReleaseSelectionTeachingClass(Page<TeachingClassCourseDto> page, Integer taskId, Integer handleState, String gradeId, Long majorId, String keyWord, Integer minClassNum);

    List<CourseAndMajor> getAllProhibitCourses(Integer taskId,List<Long> courseIds);

    List<AllScheduleVo> getTeachingClassNameForSchedule(Integer taskId, int deleted);


    List<Long> getClassIdsByTaskId(List<Integer> taskIds);

    List<TeachingClassCourseDto> getTeachingClassAndHourType(List<Long> teachingClassIds);

    List<TeachingClass> getCourseFixV2(Integer taskId, String gradeId, Long courseId);

    List<Long> getSelectionTeachingClassByWeek(Integer taskId);

    List<Long> selectSubCourse(Integer taskId);

    List<TeachingClass> getTeacherTeachingClassList(Integer taskId);
}
